%% -*- mode: erlang; erlang-indent-level: 4; indent-tabs-mode: nil -*-
{application, aecore,
 [{description, "Blockchain for aeapps"},
  {vsn, {cmd, "cat ../../VERSION"}},
  {registered, []},
  {mod, { aecore_app, []}},
  {start_phases, [
                  {create_metrics_probes, []},
                  {start_reporters, []}
                 ]},
  {applications,
   [kernel,
    stdlib,
    crypto,
    sext,
    parse_trans,
    syntax_tools,
    compiler,
    goldrush,
    gproc,
    jobs,
    exometer_core,
    redbug,
    yamerl,
    setup,
    lager,
    aeutils,
    base58,
    sha3,
    enacl,
    enoise,
    jsx,
    idna,
    inets,
    nat,
    aeminer,
    aetx,
    aevm,
    aeprimop,
    aeoracle,
    aecontract,
    aebytecode,
    aens,
    aega,
    aefate,
    aeserialization,
    ranch,
    aecli
  ]},
  {runtime_dependencies, ["app_ctrl-0.1.0"]},
  {env, [
         {'$app_ctrl',
          [
            {roles,
             [ {basic, []}
             , {nosync, [aehttp, aemon]}
             , {active, [aesync, aehttp, aemon, aestratum]}
             , {dev, [aehttp, aedevmode]}
             ]}
          , {mode, normal}
          , {modes,
             [ {normal, [basic, active]}
             , {offline, [basic, nosync]}
             , {maintenance, [basic]}
             , {dev_mode, [basic, dev]}
             ]}
          , {modify,
             [ {protected_mode_apps, [{add, [lager, mnesia]}]}
             ]}
          ]},
         {exometer_predefined,
          {script, "$PRIV_DIR/exometer_predefined.script"}},
         {exometer_defaults,
          {script, "$PRIV_DIR/exometer_defaults.script"}},
         {exometer_subscribers,
          [
           {select,
            {[
              {{[ae,epoch|'_'],counter,enabled},[],['$_']},
              {{[ae,epoch|'_'],gauge,enabled},[],['$_']}
             ],
             aec_metrics_main, [value], default, true}},
           {select,
            {[
              {{[ae,epoch|'_'],'$1',enabled},[{'=/=','$1',counter},
                                              {'=/=','$1',gauge}], ['$_']}
             ],
             aec_metrics_main, default, default, true}}
          ]},
         {metrics_probes,
          [{[ae,epoch,aecore,chain], aec_chain_metrics_probe},
           {[ae,epoch,aecore,tx_pool], aec_tx_pool_metrics_probe},
           %% TODO: Change the metric name below from "eper" to "monitor"
           {[ae,epoch,aecore,eper] , aec_monitor_metrics_probe}]},
         {'$setup_hooks',
          [
           %% The different hooks *could* be placed in the app env of each
           %% corresponding application. This would be less transparent, though.
           {normal, [
                     {110, {aecore_env, check_env, []}},
                     {110, {aehttp_app, check_env, []}},
                     {110, {aec_consensus, check_env, []}},
                     {110, {aec_hard_forks, ensure_env, []}},
                     {110, {aec_dev_reward, ensure_env, []}},                    
                     {110, {aec_mining, check_env, []}},
                     {200, {aec_db, check_db, []}},
                     {210, {aec_db, start_db, []}},
                     {1000, {aecore_app, set_app_ctrl_mode, []}}
                    ]}
          ]}
        ]},
  {modules, []},

  {maintainers, []},
  {licenses, []},
  {links, []}
 ]}.
